let str = "Hello World";
let newStr = str.replace("World", "JavaScript");
console.log(newStr); // 输出: Hello JavaScript

let str2 = "apple, banana, apple";
let newStr2 = str2.replace(/apple/g, "orange");
console.log(newStr2); // 输出: orange, banana, orange

let str3 = "I have 10 apples and 5 bananas";
let newStr3 = str3.replace(/\d+/g, function(match) {
    return parseInt(match) * 2;
});
console.log(newStr3); // 输出: I have 20 apples and 10 bananas
